package com.test.daily.leetcode.y2022.m06.day0604.v02;

import java.util.HashSet;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/6/4 下午 07:11
 * @version: 1.0
 */
public class Solution {
    public static void main(String[] args) {
        String[] test = new String[]{"test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"};
        System.out.println(new Solution().numUniqueEmails(test));

    }
    public int numUniqueEmails(String[] emails){
        if(emails.length == 0){
            return 0;
        }
        HashSet<String> ans = new HashSet<>();
        for(int i = 0; i < emails.length; i++){
            String[] splits = emails[i].split("@");
            splits[0] = splits[0].replaceAll("\\.","");
            splits[0] = splits[0].split("\\+")[0];
            ans.add(splits[0] +"@"+ splits[1]);
        }
        return ans.size();
    }
}
